let fs=require('fs')
let path=require('path')
let cssReg=/<style>([\s\S]*)<\/style>/
let jsReg=/<script>([\s\S]*)<\/script>/
function mackCss(data) {
    let result=cssReg.exec(data)
    fs.writeFile(path.join(__dirname,'a2time','index.css',),result[1],(err)=> {
        if(err) return console.log(err);
        console.log('成功');
    })
}
function mackJs(data) {
    let result=jsReg.exec(data)
    fs.writeFile(path.join(__dirname,'a2time','index.js'),result[1],(err)=> {
        if(err) return console.log(err);
        console.log('成功');
    })
}
function mackHtml(data) {
    data=data.replace(cssReg,`<link rel="stylesheet" href='index.css'>`)
    data=data.replace(jsReg,`<script src='index.js'></script>`)
    fs.writeFile(path.join(__dirname,'a2time','index.html'),data,(err)=>  {
        if(err) return console.log(err);
        console.log('成功');
    })
}
fs.readFile(path.join(__dirname,'index.html'),'utf8',(err,data)=> {
     if(err) return console.log(err);
    

    mackCss(data)
    mackHtml(data)
    mackJs(data) 
})
